package com.foreknow.oop7;

public class TestDemo {
  public B m1() {
    B b = new B();
    return b;
  }

  public A m2(){
    A a = new A();
    return a;
  }

  public A m3(){
    A x = new B();
    return x; //返回的是子类的对象
  }

  public A m4(A a){ //a指向是B类的对象
    return a;
  }

  public static void main(String[] args) {
    TestDemo testDemo = new TestDemo();
    B bb = testDemo.m1();
    bb.func();

    A aa = testDemo.m2();
    aa.func();

    A aaa = testDemo.m3();
    aaa.func();

    A bbb = new B();
    A as = testDemo.m4(bbb);
    as.func();
  }
}
